import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

public class Test {
    public static void main(String[] args) {
        List<Integer> list = new LinkedList<>();
        list.add(1);
        list.add(2);
        list.add(3);

        for(int x : list) {
            System.out.println(x);
        }

        System.out.println("=====");
        ListIterator<Integer> it =  list.listIterator();
        while (it.hasNext()) {
            System.out.print(it.next()+" ");
        }

        System.out.println();
        System.out.println("=====");
        ListIterator<Integer> it2 =  list.listIterator(list.size());
        //逆序打印，反向打印
        while (it2.hasPrevious()) {
            System.out.print(it2.previous()+" ");
        }
        System.out.println();
    }
    public static void main1(String[] args) {
        MyLinkedList myLinkedList = new MyLinkedList();
        myLinkedList.addFirst(1);
        myLinkedList.addFirst(2);
        myLinkedList.addFirst(3);
        myLinkedList.addFirst(4);
        myLinkedList.display();
        System.out.println(myLinkedList.size());
        System.out.println(myLinkedList.contains(10));


        MyLinkedList myLinkedList1 = new MyLinkedList();
        myLinkedList1.addLast(1);
        myLinkedList1.addLast(2);
        myLinkedList1.addLast(3);
        myLinkedList1.addLast(4);
        myLinkedList1.addLast(4);
        myLinkedList1.display();


//        myLinkedList1.addIndex(3,5);
//        myLinkedList1.display();

//        myLinkedList1.removeAllKey(4);
//        myLinkedList1.display();


        myLinkedList1.clear();
        myLinkedList1.display();
    }
}
